package com.example.finalhomework_lienyu.util_classes;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class SQLiteDataBaseHelper extends SQLiteOpenHelper {
    private static final String DATABASE_NAME = "ticketBooking.db";
    private static final int DATABASE_VERSION = 2;

    public static final String TABLE_TICKETS = "tickets";
    public static final String COLUMN_ID = "_id";
    public static final String COLUMN_DATE = "date";
    public static final String COLUMN_TIME = "time";
    public static final String COLUMN_CATEGORY = "category";
    public static final String COLUMN_NUMBER = "number";
    public static final String COLUMN_USER_ID = "user_id"; // Add this line

    private static final String TABLE_CREATE =
            "CREATE TABLE " + TABLE_TICKETS + " (" +
                    COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
                    COLUMN_DATE + " TEXT, " +
                    COLUMN_TIME + " TEXT, " +
                    COLUMN_CATEGORY + " TEXT, " +
                    COLUMN_NUMBER + " INTEGER, " +
                    COLUMN_USER_ID + " TEXT);"; // Update schema

    public SQLiteDataBaseHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(TABLE_CREATE);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS " + TABLE_TICKETS);
        onCreate(db);
    }
}

